<?php
/*
 * @Author: 莫莫
 * @Phone: 13450159681
 * @Description: 
 * @Date: 2024-10-22 17:06:17
 * @LastEditTime: 2025-03-19 21:53:28
 */

namespace app\model;

use think\Model;

class OrderStaff extends Model
{

	protected $connection = 'mysql';

	protected $pk = 'id';

	protected $name = 'order_staff';

	public static function getuuid($order_id)
	{
		$staff = self::where('order_id', $order_id)->order('id desc')->column('uuid');
		return $staff;
	}
	public static function is_staff($order_id)
	{
		$staff = self::where('order_id', $order_id)->order('id desc')->find();
		return $staff->id;
	}

	public static function staff($order_id)
	{
		$staff = self::where('order_id', $order_id)->order('id desc')->find();
		return Technical::getTitle($staff->uuid);
	}

	public static function staff_tel($order_id)
	{
		$staff = self::where('order_id', $order_id)->order('id desc')->find();
		return Technical::getTel($staff->uuid);
	}
	public static function addstaff($order_staff, $is_del = 0)
	{
		if ($is_del) {
			self::where('order_id', $order_staff['order_id'])->delete();
		}

		$res = self::create($order_staff);

		if (!empty($res)) {
			Broadcast::staff($order_staff);

			return $res;
		}
	}
}
